package team.knowers.qzh.qzhadmin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import team.knowers.qzh.qzhadmin.config.convention.result.Result;
import team.knowers.qzh.qzhadmin.config.convention.result.Results;
import team.knowers.qzh.qzhadmin.dto.req.PageCourseReqDTO;
import team.knowers.qzh.qzhadmin.dto.req.PageCourseReqDTO1;
import team.knowers.qzh.qzhadmin.dto.resp.CourseMessageRespDTO;
import team.knowers.qzh.qzhadmin.dto.resp.CoursePageRespDTO;
import team.knowers.qzh.qzhadmin.dto.resp.PageCourseMessageRespDTO;
import team.knowers.qzh.qzhadmin.service.CourseAdminService;

@RestController
@RequiredArgsConstructor
public class CourseAdminController {
    private final CourseAdminService courseAdminService;


    /**
     *课程审查通过
     *
     */
    @PutMapping("/api/qzh-admin/admin/v1/course/examine/yes/{id}")
    public Result<String> examineCourse(@PathVariable("id") Long id){
        return Results.success(courseAdminService.examineCourse(id));
    }
    /**
     *课程审查未通过
     *
     */
    @PutMapping("/api/qzh-admin/admin/v1/course/examine/not/{id}")
    public Result<String> notExamineCourse(@PathVariable ("id") Long id){
        return Results.success(courseAdminService.notExamineCourse(id));
    }
    /**
     * 查询课程
     */
    @PutMapping("/api/qzh-admin/admin/v1/course/show")
    public Result<IPage<PageCourseMessageRespDTO>> showCourse(@RequestBody PageCourseReqDTO req)
    {
        return Results.success(courseAdminService.showCourse(req));
    }
    /**
     * 查看创作课程
     *
     */
    @PostMapping("/api/qzh-admin/admin/v1/course/show")
    public Result<IPage<CoursePageRespDTO>> pageCourse(@RequestBody PageCourseReqDTO1 req){
        return Results.success(courseAdminService.pageCourse(req));
    }
    /**
     * 展示单个课程
     *
     */
    @GetMapping("/api/qzh-admin/admin/v1/course/show/{id}")
    public Result<CourseMessageRespDTO>  showCourse(@PathVariable("id") Long id)
    {
        return Results.success(courseAdminService.showCourse(id));
    }


}
